package com.wiz.web;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import com.wiz.common.Constant;
import com.wiz.to.AdminTO;

public class UserTracker implements Constant {

    public static boolean isLogined(HttpServletRequest request) {
        return request.getSession().getAttribute(COOKIE_USER_INFO) != null;
    }
    

    public static AdminTO getAdminTO(HttpServletRequest request) {
        Object obj=request.getSession().getAttribute(COOKIE_USER_INFO);
        if(obj == null) {
            return null;
        }
        return (AdminTO)obj;
    }

    public static void remeberAdmin(HttpServletRequest request, AdminTO adminTO) {
        HttpSession session=request.getSession();
        session.setMaxInactiveInterval(-1);// 永不超时
        session.setAttribute(COOKIE_USER_INFO, adminTO);
    }

    public static void removeUser(HttpServletRequest request) {
        request.getSession().setAttribute(COOKIE_USER_INFO, null);
    }
//
//	public static void remeberUser(HttpServletRequest request, AdminTO adminTO) {
//		HttpSession session=request.getSession();
//		adminTO.setPassword("");
//        session.setAttribute(COOKIE_USER_INFO, adminTO);
//	}
}
